HAL SMBUS types migration

This section provides information about the HAL SMBUS types migration.

HAL SMBUS callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_SMBUS_MASTER_TX_COMPLETE_CB_ID,
  HAL_SMBUS_MASTER_RX_COMPLETE_CB_ID,
  HAL_SMBUS_SLAVE_TX_COMPLETE_CB_ID,
  HAL_SMBUS_SLAVE_RX_COMPLETE_CB_ID,
  HAL_SMBUS_LISTEN_COMPLETE_CB_ID,
  HAL_SMBUS_ERROR_CB_ID,
  HAL_SMBUS_ABORT_CB_ID,
  HAL_SMBUS_MSPINIT_CB_ID,
  HAL_SMBUS_MSPDEINIT_CB_ID
} HAL_SMBUS_CallbackIDTypeDef;

Removed. The callback registration in HAL2 is handled by specific functions for each SMBUS event. For more details, see : HAL SMBUS callbacks register and unregister functions

HAL_SMBUS_MSPINIT_CB_ID and HAL_SMBUS_MSPDEINIT_CB_ID are removed because the functions HAL_SMBUS_MspInit() and HAL_SMBUS_MspDeInit() are removed.

Related concepts:


HAL SMBUS mode type definition

HAL1

HAL2

In HAL1, this enumeration is used in some series only, the majority of series used HAL SMBUS peripheral modes constants.

In HAL2, only one single enumeration used HAL SMBUS peripheral modes constants.

typedef enum
{
  HAL_SMBUS_MODE_NONE /* No communication on going */
  HAL_SMBUS_MODE_MASTER
  HAL_SMBUS_MODE_SLAVE
} HAL_SMBUS_ModeTypeDef;
typedef enum
{
 /* MODE NONE removed */
  HAL_SMBUS_PERIPHERAL_MODE_HOST
  HAL_SMBUS_PERIPHERAL_MODE_SLAVE      /* SMBUS Slave default mode                */
  HAL_SMBUS_PERIPHERAL_MODE_SLAVE_ARP  /* SMBus Slave Default address acknowledge */
} hal_smbus_mode_t;

HAL SMBUS state type definition

HAL1

HAL2

In HAL1, this enumeration is used in some series only, the majority of series used HAL SMBUS state code constants.

In HAL2, only one single enumeration used HAL SMBUS state code constants.

typedef enum
{
  HAL_SMBUS_STATE_RESET
  HAL_SMBUS_STATE_READY
  HAL_SMBUS_STATE_BUSY
  HAL_SMBUS_STATE_BUSY_TX
  HAL_SMBUS_STATE_BUSY_RX
  HAL_SMBUS_STATE_LISTEN
  HAL_SMBUS_STATE_BUSY_TX_LISTEN
  HAL_SMBUS_STATE_BUSY_RX_LISTEN
  HAL_SMBUS_STATE_ABORT
  HAL_SMBUS_STATE_TIMEOUT
  HAL_SMBUS_STATE_ERROR
} HAL_SMBUS_StateTypeDef;
typedef enum
{
  HAL_SMBUS_STATE_RESET
  HAL_SMBUS_STATE_INIT
  HAL_SMBUS_STATE_IDLE
  HAL_SMBUS_STATE_TX
  HAL_SMBUS_STATE_RX
  HAL_SMBUS_STATE_LISTEN
  HAL_SMBUS_STATE_TX_LISTEN
  HAL_SMBUS_STATE_RX_LISTEN
  HAL_SMBUS_STATE_ABORT
} hal_smbus_state_t;

Related concept: Revised and optimized HAL state machine


HAL SMBUS autonomous mode configuration type definition

HAL1

HAL2

typedef struct
{
  uint32_t TriggerState;




  uint32_t TriggerSelection;
  uint32_t TriggerPolarity;
} SMBUS_AutonomousModeConfTypeDef;
/* */

hal_status_t HAL_SMBUS_AM_EnableTrigger(hal_smbus_handle_t *hsmbus);
hal_status_t HAL_SMBUS_AM_DisableTrigger(hal_smbus_handle_t *hsmbus);

typedef struct
{
  hal_smbus_am_trig_source_t    source;
  hal_smbus_am_trig_polarity_t  trigger_polarity;
} hal_smbus_am_trig_config_t;

Related concepts:


HAL SMBUS handle type definition

HAL1

HAL2

SMBUS_HandleTypeDef;
hal_smbus_handle_t;

Related concepts:


HAL SMBUS initialization type definition

  • The hal_smbus_config_t structure is simplified to include only the mandatory parameters. Other parameters are optional and can be handle it through dedicated HAL_SMBUS_Enable/Disable{feature} or HAL_SMBUS_Set/Get{feature}.

HAL1

HAL2

The reason for removing AddressingMode can be found in HAL SMBUS addressing modes constants, and for more details about NoStretchMode you can refer to HAL SMBUS no stretch states constants

typedef struct
{
  uint32_t Timing;

  uint32_t OwnAddress1;

  uint32_t PeripheralMode;



  uint32_t AnalogFilter;



  uint32_t DualAddressMode;

  uint32_t OwnAddress2;

  uint32_t OwnAddress2Masks;


  uint32_t GeneralCallMode;



  uint32_t PacketErrorCheckMode;




  uint32_t SMBusTimeout;



  uint32_t AddressingMode;

  uint32_t NoStretchMode;

} SMBUS_InitTypeDef;
typedef struct
{
  uint32_t         timing;

  uint32_t         own_address1;

  hal_smbus_mode_t device_mode;

} hal_smbus_config_t;

hal_status_t HAL_SMBUS_EnableAnalogFilter(hal_smbus_handle_t *hsmbus);
hal_status_t HAL_SMBUS_DisableAnalogFilter(hal_smbus_handle_t *hsmbus);



hal_status_t HAL_SMBUS_SetConfigOwnAddress2(hal_smbus_handle_t *hsmbus, uint32_t addr, hal_smbus_own_addr2_mask_t mask);
void HAL_SMBUS_GetConfigOwnAddress2(const hal_smbus_handle_t *hsmbus, uint32_t *p_addr, hal_smbus_own_addr2_mask_t *p_mask);
hal_status_t HAL_SMBUS_EnableOwnAddress2(hal_smbus_handle_t *hsmbus);
hal_status_t HAL_SMBUS_DisableOwnAddress2(hal_smbus_handle_t *hsmbus);


hal_status_t HAL_SMBUS_SLAVE_EnableAckGeneralCall(hal_smbus_handle_t *hsmbus);
hal_status_t HAL_SMBUS_SLAVE_DisableAckGeneralCall(hal_smbus_handle_t *hsmbus);


hal_status_t HAL_SMBUS_EnablePacketErrorCheck(hal_smbus_handle_t *hsmbus);
hal_status_t HAL_SMBUS_DisablePacketErrorCheck(hal_smbus_handle_t *hsmbus);


hal_status_t HAL_SMBUS_EnableTimeout(hal_smbus_handle_t *hsmbus, const hal_smbus_timeout_t timeout);
hal_status_t HAL_SMBUS_DisableTimeout(hal_smbus_handle_t *hsmbus, const hal_smbus_timeout_t timeout);



/* AddressingMode is removed from HAL2 */

/* NoStretchMode is removed from HAL2 */

Related concept: Removal and conversion of init structure to configuration structure


HAL SMBUS callback type definition

HAL1

HAL2

pSMBUS_CallbackTypeDef

hal_smbus_cb_t

Related concept: Replaced TypeDef suffix with _t in type names

HAL SMBUS address callback type definition

HAL1

HAL2

pSMBUS_AddrCallbackTypeDef

hal_smbus_slave_addr_cb_t

Related concept: Replaced TypeDef suffix with _t in type names